package com.hnhd.eorder.activity;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.hnhd.eorder.R;

/**
 * ���������
 * @author dengbiao
 *
 */
public class OrderDishActivity extends Activity {

	//��Ʒ�������  --��񲼾�
	public GridView gv_order_menu_list;

	//ÿ����Ʒ����Ҫ�����������
	public String[] from = {"background", "item_name" };

	//Ҫ����id����
	public int[] to = {R.id.layout_menu_item_background, R.id.tv_menu_item_name };

	public GridView gv_order_dish_grid;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_orderdish);

		//��񲼾�  ������ʾ��Ʒ����
		gv_order_menu_list = (GridView) findViewById(R.id.gv_order_menu_list);
		this.initGridView(gv_order_menu_list, from, to);
		
		gv_order_dish_grid = (GridView)findViewById(R.id.gv_order_dish_grid);
		this.initGridView2(gv_order_dish_grid, new String[]{}, new int[]{});
		
		
		ListView lv_order_recommend_list = (ListView)findViewById(R.id.lv_order_recommend_list);
		this.initListView(lv_order_recommend_list, new String[]{}, new int[]{});
	}
	
	private void initListView(ListView listView, String[] from, int[] to) {
		ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
		
		for (int i = 0; i < 10; i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			list.add(map);
		}
		SimpleAdapter adapter = new SimpleAdapter(this, list,R.layout.whatdishchilditem, from, to);
		listView.setAdapter(adapter);
	}
	
	private void initGridView2(GridView gridView, String[] from, int[] to) {
		ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

		for(int i=0;i<8;i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			list.add(map);
		}
	
		SimpleAdapter adapter = new SimpleAdapter(this, list,
				R.layout.item_goods_view_grid, from, to);
		gridView.setAdapter(adapter);
	}

	private void initGridView(GridView gridView, String[] from, int[] to) {
		ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put(from[0], R.drawable.p2);
		map.put(from[1], "��Ʒ");
		list.add(map);
		
		map = new HashMap<String, Object>();
		map.put(from[0], R.drawable.p3);
		map.put(from[1], "��ʳ");
		list.add(map);
		
		map = new HashMap<String, Object>();
		map.put(from[0], R.drawable.p4);
		map.put(from[1], "����");
		list.add(map);
		
		map = new HashMap<String, Object>();
		map.put(from[0], R.drawable.p5);
		map.put(from[1], "��ˮ");
		list.add(map);
		
		map = new HashMap<String, Object>();
		map.put(from[0], R.drawable.p6);
		map.put(from[1], "���");
		list.add(map);

		SimpleAdapter adapter = new SimpleAdapter(this, list,
				R.layout.order_menu_item, from, to);
		gridView.setAdapter(adapter);
	}

}
